<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="function.jsp"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>级别描述</title>
    <link rel="stylesheet" href="/css/public.css?cache=<%=Math.random()%>">
    <link  href="../../hos_manage/images/favicon.ico?cache=<%=Math.random()%>" rel="shortcut icon" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="../../css/palace/message/level_describe.css?a=<%=Math.random()%>">
    <script src="/js/jquery-1.9.1.min.js"></script>
</head>
<body id="app" v-cloak>
<%@ include file="../../header.jsp"%>
<!--内容-->
<div class="containerone">
    <%@ include file="../../left_menu.jsp"%>
    <!--右边内容-->
    <div class="right_cont">
        <!--右边导航下面内容-->
        <div class="address-book">
            <div class="title">
                <div class="address-left show-block note">
                    <span @click="homePage()" class="hover">首页</span>
                    <span class="left-distance">></span>
                    <span class="left-distance point hover" @click="messageCenter()">通知列表</span>
                    <span class="left-distance">></span>
                    <span class="left-distance">通知级别</span>
                </div>
                <div class="title-right center" @click="addLevelOpen()">添加级别</div>
            </div>
            <div class="container">
                <div class="position">
                    <div class="show-block address-book-right">
                        <div class="all-operate create">
                            <div class="show-block">批量导入</div>
                            <div class="show-block address-left">全部导出</div>
                        </div>
                        <div class="data-form show-margin-left line">
                            <div class="form-title">
                                <div class="show-block title-width center">级别</div>
                                <div class="show-block title-width center">描述</div>
                                <div class="show-block title-width center">颜色</div>
                                <div class="show-block title-width center">操作</div>
                            </div>
                            <div class="form-title bg-white line" v-for="i in levelList">
                                <div class="show-block title-width center" v-html="i.name"></div>
                                <div class="show-block title-width center" v-html="i.condition"></div>
                                <div class="show-block title-width center">
                                    <div class="circle" :style="{backgroundColor: i.color}"></div>
                                </div>
                                <div class="show-block title-width center">
                                    <img class="img" src="../../images/palace/tag/del.png" @click="deleteLevel(i.id)">
                                </div>
                            </div>
                        </div>
                        <pagination :pagecount="page_count" :currentpage="current_page"></pagination>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <addlevel v-if="addlevelShow"></addlevel>
    <delete v-if="deleteShow" :top="delete.top" :title="delete.title" :content="delete.content" :arg="delete.arg"></delete>
    <dangertip v-if="dangerTipShow" :title="dangerTitle"></dangertip>
    <meesagetip v-if="messageTipShow" :title="messageTitle"></meesagetip>
</div>
</body>
<%@ include file="/components/tag/add_level.jsp"%>
<%@ include file="/components/pagination.jsp"%>
<%@ include file="/components/danger.jsp"%>
<%@ include file="/components/message.jsp"%>
<%@ include file="/components/delete.jsp"%>
<script>
    new Vue({
        el: "#app",
        data: {
            addlevelShow: false,
            levelList: [],
            page_count: 0,
            current_page: 1,
            deleteShow: false,
            dangerTitle: "",
            dangerTipShow: false,
            messageTitle: "",
            messageTipShow: false,
            delete: {
                top: "",
                title: "",
                content: "",
                arg: {},
            },
            deleteShow: false,
        },
        events: {
            danger: function(title) {
                this.dangerTitle = title;
                this.dangerTipShow = true;
            },
            dangerTipOver: function() {
                this.dangerTipShow = false;
            },
            message: function(title) {
                this.messageTitle = title;
                this.messageTipShow = true;
            },
            // 消息消失的方法,
            messageTipOver: function() {
                this.messageTipShow = false;
            },
        },
        methods: {
            danger: function(title) {
                this.dangerTitle = title;
                this.dangerTipShow = true;
            },
            message: function(title) {
                this.messageTitle = title;
                this.messageTipShow = true;
            },
            addLevelOpen: function() {
                this.addlevelShow = true;
            },
            getData: function() {
                var self = this;
                $.ajax({
                    type: "post",
                    url: "level_describe.jsp",
                    data: {
                        act: "levelListContent",
                        hospital: "${user.hospital}",
                        page: this.current_page + "",
                    },
                    success: function (res) {
                        res = JSON.parse(res);
                        if (res.errcode == "0") {
                            self.levelList = res.data.list;
                            self.page_count = parseInt(res.data.pages);
                        } else {
                            self.danger(res.errmsg);
                        }
                    }
                })
            },
            homePage: function () {
                location.href = "../../index.jsp";
            },
            messageCenter: function () {
                locationHerf("message_center");
            },
            deleteLevel: function (obj) {
                var self = this;
                self.deleteShow = true;
                self.delete.top = "删除等级";
                self.delete.title = "确定删除等级";
                self.delete.content = "即将删除等级";
                self.delete.arg = function () {
                    $.ajax({
                        type: "post",
                        url: "level_describe.jsp",
                        data: {
                            act: "deleteLevel",
                            id: obj,
                        },
                        success: function (res) {
                            res = JSON.parse(res);
                            console.log(res);
                            if (res.errcode == "0") {
                                self.message("删除成功!");
                                self.getData();
                            } else {
                                self.danger(res.errmsg);
                            }
                        }
                    })
                }
            }
        },
        events: {
            addLevel: function() {
                this.addlevelShow = false;
                this.getData();
            },
            closeEditTagShow: function() {
                this.addlevelShow = false;
            },
            changePage: function(i) {
                this.current_page = i.currentpage;
                this.getData();
            },
            danger: function(title) {
                this.dangerTitle = title;
                this.dangerTipShow = true;
            },
            dangerTipOver: function() {
                this.dangerTipShow = false;
            },
            message: function(title) {
                this.messageTitle = title;
                this.messageTipShow = true;
            },
            // 消息消失的方法,
            messageTipOver: function() {
                this.messageTipShow = false;
            },
            deleteCancel: function() {
                this.deleteShow = false;
            },
        },
        ready: function() {
            this.getData();
        },
        components: {
            addlevel: addLevel,
            pagination: pagination,
            message: messageTip,
            dangertip: dangerTip,
            meesagetip: messageTip,
            delete: deleteTip,
        }
    });
</script>
</html>
